import { searchClass, shopList } from "@/service/api/sp-product/index";
const state = {
  skuList: [],
  specList: [],
  storeList: [],
  classifyList: [],
  shopList: [],
};

const mutations = {
  SET_SKULIST: (state, data) => {
    state.skuList = data;
  },
  SET_SPECLIST: (state, data) => {
    state.specList = data;
  },
  SET_STORELIST: (state, data) => {
    state.storeList = data;
  },
  SET_CLASSIFY_LIST: (state, data) => {
    state.classifyList = data;
  },
  SET_SHOP_LIST: (state, data) => {
    state.shopList = data;
  },
};

const actions = {
  setSkuList({ commit }, data) {
    commit("SET_SKULIST", data);
  },
  setSpecList({ commit }, data) {
    commit("SET_SPECLIST", data);
  },
  setStoreList({ commit }, data) {
    commit("SET_STORELIST", data);
  },
  setCalssifyList({ commit }) {
    searchClass({
      title: "",
    }).then((res) => {
      commit("SET_CLASSIFY_LIST", res);
    });
  },
  setShopList({ commit }) {
    shopList({
      disabled: false,
    }).then((res) => {
      commit("SET_SHOP_LIST", res);
    });
  },
};

const getter = {
  skuList(state) {
    return state.skuList;
  },
  specList(state) {
    return state.skuList;
  },
  storeList(state) {
    return state.skuList;
  },
  classifyList(state) {
    return state.classifyList;
  },
  shopList(state) {
    return state.shopList;
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getter,
};
